#ifndef CANVAS_H
#define CANVAS_H

#include <QWidget>
#include <QMouseEvent>
#include <QPen>
#include "point3d.h"

#define NULLPOINT QPoint(-1,-1)

namespace Ui {
    class Canvas;
}

class Canvas : public QWidget
{
    Q_OBJECT

    QImage buffer;
    QPoint lastLeft;

    QPen m_black;
    QPen m_pointBlack;

    QPen m_green;
    QPen m_pointGreen;

signals:
    void left(QPoint);
    void leftRelease();

public:
    explicit Canvas(QWidget *parent = 0);
    ~Canvas();

    void drawCurvePoligonal(const std::vector<Point3D>& points, bool original = false);
    void clear();

private:
    Ui::Canvas *ui;

    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void resizeEvent(QResizeEvent *);
    void setupBuffer();
    void paintBuffer();
};

#endif // CANVAS_H
